﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _026
{
    public class Website
    {
        private string name;
        private string url;
        public Website(string a,string b)
        {
            this.name = a;
            this.url = b;
        }
        public void Display()
        {
            Console.WriteLine(name+" "+url);
        }
    }
    public class Student
    {
        private Student()
        {
        }
        public static int id;
        public static string name;
        public static void  Display()
        {
            Console.WriteLine("姓名："+name+"编号"+id);
        }
    }
    internal class Program
    {
        public static int num = 0;//构造函数
        Program()
        {
            num = 1;
        }
        //静态构造函数
        static Program()
        {
            num = 2;
        }
        static void Main(string[] args)
        {
            Test1 a = new Test1();
            Console.WriteLine("temp0:{0},temp1:{1}", a[0], a[1]);
            a[0] = 1;
            a[1] = 20;
            Console.WriteLine("temp0:{0},temp1:{1}", a[0], a[1]);

            Website site = new Website("C#编程", "http://c.biancheng.net/");
            site.Display();

            Student.id = 101;
            Student.name = "张三";
            Student.Display();

            Console.WriteLine("num={0}",num);
            Program Obj = new Program();
            Console.WriteLine("num={0}",num);

            Console.Read();
        }
    }
    public class Test
    {
        public Test()
        {
            Console.WriteLine("无参构造函数");
        }
        public Test(string text):this()
        {
            Console.WriteLine(text) ;
            Console.WriteLine("实例化构造函数");
        }
    }
    public class Test1
    {
        int temp0;
        int temp1;
        public int this[int index]
        {
            get
            {
                return (0 == index) ? temp0 : temp1;

            }
            set
            {
                if(0==index)
                {
                    temp0 = value;
                }
                else
                {
                    temp1 = value;
                }
            }
        }
    }
}
